<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Registration</title>
    </h:head>
    <h:body>
        <h:form id="registrationform">
            <p:panel header="Registration Form">
         
                <h:panelGrid columns="3"  id="regGrid">
                    <h:outputLabel for="username">Username: *</h:outputLabel>
                    <p:inputText id="username" value="#{registrationBean.user.username}">
                        <p:ajax event="keyup" update="usernameinfos"/>
                    </p:inputText>
                    <p:outputPanel id="usernameinfos" style="display: block">
                        <h:outputText value="#{registrationBean.checkUser}"/>
                        <p:message id="usernamemsg" for="username" />
                    </p:outputPanel>
                    
                    <h:outputLabel for="email">Email: *</h:outputLabel>
                    <p:inputText id="email" value="#{registrationBean.user.email}" >
                        <p:ajax update="emailmsg"/>
                    </p:inputText>
                    <p:message id="emailmsg" for="email"/>
                    
                    <h:outputLabel for="password">Password: *</h:outputLabel>
                    <p:password id="password" value="#{registrationBean.user.password}"
                                feedback="true" match="pwd2" label="Password"/>
                    <p:message for="password" />

                    <h:outputLabel for="pwd2">Confirm Password: *</h:outputLabel>
                    <p:password id="pwd2" label="Confirm Password"/>
                    <p:message for="pwd2" />
                    
                    <h:outputLabel for="name">Name: *</h:outputLabel>
                    <p:inputText id="name" value="#{registrationBean.user.name}" >
                        <p:ajax update="name"/>
                    </p:inputText>
                    <p:message id="namemsg" for="name"/>

                    <h:outputLabel for="surname">Surname: *</h:outputLabel>
                    <p:inputText id="surname" value="#{registrationBean.user.surname}" >
                        <p:ajax update="emailmsg"/>
                    </p:inputText>
                    <p:message id="surnamemsg" for="surname"/>

                    <h:outputLabel for="city">City:</h:outputLabel>
                    <p:inputText id="city" value="#{registrationBean.user.city}" >
                        <p:ajax update="citymsg"/>
                    </p:inputText>
                    <p:message id="citymsg" for="city"/>

                    <h:outputLabel for="state">State:</h:outputLabel>
                    <p:inputText id="state" value="#{registrationBean.user.state}" >
                        <p:ajax update="statemsg"/>
                    </p:inputText>
                    <p:message id="statemsg" for="state"/>

                    <h:outputLabel for="address">Address:</h:outputLabel>
                    <p:inputText id="address" value="#{registrationBean.user.address}" >
                        <p:ajax update="addressmsg"/>
                    </p:inputText>
                    <p:message id="addressmsg" for="address"/>

                    <h:outputLabel for="telephone">Telephone:</h:outputLabel>
                    <p:inputText id="telephone" value="#{registrationBean.user.telephone}" >
                        <p:ajax update="telephonemsg"/>
                    </p:inputText>
                    <p:message id="telephonemsg" for="telephone"/>
                    
                </h:panelGrid>
                <p:commandButton id="submit" value="Register" update="regGrid"
                                 action="#{registrationBean.register()}" />

            </p:panel>
        </h:form>
    </h:body>
</html>

